var vm = new Vue({
    el: '#my_app1',
    delimiters: ['[[',']]'],
    data: {
        token: '',
        user_head_img: '',
        now_movie_list: [],
        now_count: '',
        about_movie_list: [],
        about_count: '',
        canon_movie_list: [],
        canon_count: '',

    },
    mounted(){
        this.token = getCookie('token');
        this.getUserHead();
        this.getMovieInfo();
    },
    methods: {
        getMovieInfo(){
            var url = host + '/movie/get_index_movie_info/'
            axios.get(url,{
                headers: {
                    'Authorization': 'JWT ' + this.token
                },
                responseType: 'json',
                withCredentials:true,
            })
            .then(dat => {
                if (dat.data.code == 0){
                    this.now_movie_list = dat.data.new_now_movie_list;
                    this.about_movie_list = dat.data.new_about_movie_list;
                    this.canon_movie_list = dat.data.new_canon_movie_list;
                    this.now_count = dat.data.now_count;
                    this.about_count = dat.data.about_count;
                    this.canon_count = dat.data.canon_count;
                    console.log(now_movie_list);
                    
                    
                }else{
                    alert(dat.data.errmsg);
                    window.location.reload();
                }
            }).catch(err => {
                console.log(err);
                
            })
        },
        getUserHead() {
            var url = host + '/user/user_head/'
            axios.get(url,{
                headers: {
                    'Authorization': 'JWT ' + this.token
                },
                responseType: 'json',
                withCredentials:true,
            })
            .then(dat => {
                if (dat.data.code == 0){
                    // console.log(dat.data.img_url);
                    
                    this.user_head_img = dat.data.img_url
                }else{
                    alert(dat.data.errmsg);
                    window.location.reload();
                }
            }).catch(err => {
                console.log(err);
                
            })
        },
        logoutfunc: function () {
            var url = host + '/user/logout/';
            axios.delete(url,{
                responseType: 'json',
                withCredentials:true,
            })
                .then(respone => {
                    location.href = '/index.html'
                })
                .catch(error => {
                    console.log(error.respone);
                    
                })
        }
    }
})